'use strict';
const db = uniCloud.database();
exports.main = async (event, context) => {
	//event为客户端上传的参数
	const resData = await db.collection('bill').where({
		_id: event.id
	}).get()

	const account = await db.collection('account').where({
		_id: resData.data[0].accID
	}).get()
	
	const people = await db.collection('user').where({
		_id: db.command.in(account.data[0].userIds)
	}).get()
	
	people.data.forEach((item,index) => {
		if (item._id == resData.data[0].founderId) {
			resData.data[0].founderImg = item.avatarUrl
			people.data.splice(index,1)
		}
	})
	
	resData.data[0].people = people.data

	//返回数据给客户端
	return {
		code: 200,
		data: resData.data[0]

	}
};